Repository navigation
fix(cost): print a summary build's operation counts to three decimals - #1417
Conversation
A KMV build's compared hashes per row are fractional, so its cost detail printed e.g. "300000 rows x 304.9256135696759 ops". Print the build's and the chain's operations per row, and the state allocation's, with `:.0`, as the hash aggregate's detail already does. Charged costs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr
milindsrivastava1997
left a comment
There was a problem hiding this comment.
No bug in charged costs; the comments below are about display fidelity and test coverage.
Design note: rounding is fixed in three format strings one at a time. A single helper (e.g. fn ops(x: f64) -> String) used by the hash-aggregate, SummaryAgg, chain and allocation details would stop the next detail that interpolates an f64 count (merge_ops, estimate_ops) from repeating this.
|
Does this tackle the D2 concern in #1354 (comment)? No. That comment is about golden churn from floating-point drift in plan costs: a no-op refactor moved costs by up to 3e-11 relative, which flips the 11th–12th printed digit. It proposes a relative-tolerance comparison in the snapshot check, or printing fewer digits. This PR only rounds the ops-per-row count in a summary build's |
Review of #1417: `:.0` printed a count under 0.5 as "0 ops" while still charging it, and the detail no longer multiplied out to the charge. `operations_text` prints three decimals with trailing zeros dropped, so whole counts read as before ("121"), fractional ones keep their value ("304.926") and float noise does not show ("70"). The build, chain and allocation details use it, each pinned by its own test, over one shared fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr
|
Addressed in 72ee6fe. On the design note: one helper, Out of scope: plan-cost drift and snapshot tolerance (#1354 D2). Three decimals still flip at a rounding boundary; a tolerant snapshot comparison would cover both. |
|
Re the D2 question above: agreed, this PR does not address #1354 D2 and is not meant to. It answers the #1284 review note about the unrounded |
The KMV build's operations per row print to three decimals (116.19991733920547 -> 116.2). No plan changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr
…1278) (#1284) * test(devtools): sketch plan snapshots for 32 small single-purpose workloads (#1278) Each workload exercises one planner behavior: rollup across label sets, top-k reuse, chain widths and sharing, avg as Sum / Count, and which sketches an accuracy target or a declared value sign admits. Its `covers` line says what the workload exercises, not which plan is selected, so a plan change needs no rewording. Existing snapshots are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr * test(devtools): regenerate distinct-two-forms after #1417 The KMV build's operations per row print to three decimals (116.19991733920547 -> 116.2). No plan changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A summary build's cost detail printed its operations per row unrounded, e.g.
build Kmv into 1 states: 300000 rows x 304.9256135696759 ops(KMV's compared hashes per row are fractional). These counts now print through one helper,operations_text: three decimals, trailing zeros dropped. Whole counts print as before ("121"), fractional ones keep their value ("304.926"), and float noise doesn't show ("69.99993…" prints as "70"). Raised in the review of #1284.Review guide
crates/cost/src/node/usage/mod.rs:operations_text, used by theSummaryAggbuild detail, theSummaryTumblingWindowChainbuild detail and the state-allocation note.crates/cost/src/node/usage/tests.rs: one test for the helper and one per site, over a shared fixture (user_id_sketch_detail).:.0; the second (review) replaces it with the helper.Behavior: before → after
KMV build over 300,000 rows at k = 4,323:
Interfaces
None. Only the human-readable
detailstring changes; charged costs are unchanged.Algorithm changes
None.
Decisions and open questions
:.0::.0printed a count under 0.5 as "0 ops" while still charging it. Not plain:.3either, which would print every whole count as "121.000" and change every snapshot.{operations_per_row:.0}stays: it charges whole operations per row (rounded up).Verification
a_build_detail_prints_its_operations_per_row_to_three_decimals,a_chain_detail_prints_its_operations_per_row_to_three_decimalsanda_state_allocation_prints_to_three_decimalseach fail when their site prints the rawf64(e.g.304.9256135696759 ops) and pass with the fix.an_operation_count_prints_to_three_decimalspins the helper.cargo test -p asap-cost: 120 passed.cargo clippy -p asap-cost --tests -- -D warnings: clean.cargo test --release -p asap-devtools --test corpus_snapshots -- --include-ignored: 8 passed. No corpus or sketch-plan snapshot changes: none onmainhas a fractional operation count.Follow-ups
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_014qhwq4GZoWwtfFWWr9CKkr